package com.yeyv.net.Security;

import com.alibaba.fastjson2.JSONObject;
import com.yeyv.net.UsefulEntity.Constant;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * 验证失败时返回的信息
 * @author 夜雨
 */
@Component
public class AuthErrorPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
//        JSONObject result = JSONObject.from(Constant.ResponseAuthReject());
//        httpServletResponse.setContentType("application/json;charset=utf-8");
//        PrintWriter out = httpServletResponse.getWriter();
//        out.write(JSONObject.toJSONString(result));
//        out.flush();
//        out.close();
    }
}